{include file="common/head"}
<style>
    .hide {
        display: none;
    }
</style>
<form class="layui-form layui-form-pane layui-padding-4" action="">
    <div class="layui-form-item">
      <label class="layui-form-label">对应商品</label>
      <div class="layui-input-inline">
          <select name="good_id" id="">
             {volist name="goodList" id="good"}
             <option value="{$good.id}">{$good.good_name}</option>
             {/volist}
          </select>
      </div>
    </div>
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">卡密导入</label>
      <div class="layui-input-block">
        <textarea placeholder="请输入内容" name="fakeContent" class="layui-textarea"></textarea>
        <span>Ps：导入的卡密（一行一个卡密）</span>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit lay-filter="import">立即导入</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>

{include file="common/bottom"}
<script>
    layui.use(function () {
        const layer = layui.layer
        const form = layui.form
        $ = layui.$
        form.on('submit(import)', (data) => {
            let field = data.field
            $.ajax({
                url: '/admin/fake/doImport'
                , type: 'post'
                , dataType: 'json'
                , data: field
                , success: (res) => {
                    if (res.code) {
                        layer.msg('操作成功')
                    } else {
                        layer.msg(res.message, { icon: 5 })
                    }
                }
            })
            return false; // 阻止默认 form 跳转
        })
        // $('#type ~ .layui-form-select > .layui-anim-upbit > dd').click(() => {
        //     $('#goodLis').hide()
        //     $('#score').hide()
        //     $('#vip_time').hide()
        //     setTimeout(() => {
        //         let type = $('#type').val()
        //         if (type == 2) {
        //             $('#goodLis').show()
        //         } else if (type == 0) {
        //             $('#score').show()
        //         }else if(type == 1)
        //         {
        //             $('#vip_time').show()
        //         }
        //     }, 200)
        // })
    })

</script>